package org.javaforever.gatescore.widgets;

import java.util.ArrayList;
import java.util.List;

import org.javaforever.gatescore.core.FrontDomain;
import org.javaforever.gatescore.core.Statement;
import org.javaforever.gatescore.core.StatementList;
import org.javaforever.gatescore.core.Writeable;
import org.javaforever.gatescore.core.WriteableUtil;

public class EchartsDiagram extends Widget{
	protected FrontDomain domain;

	@Override
	public StatementList generateWidgetStatements() {
		List<Writeable> sList = new ArrayList<>();
		
		sList.add(new Statement(1000L,0,"<el-select v-model=\"chartType\" placeholder=\"请选择\" @change=\"setup\">"));
		sList.add(new Statement(2000L,1,"<el-option"));
		sList.add(new Statement(3000L,1,"v-for=\"item in chartTypes\""));
		sList.add(new Statement(4000L,1,":key=\"item.value\""));
		sList.add(new Statement(5000L,1,":label=\"item.label\""));
		sList.add(new Statement(6000L,1,":value=\"item.value\">"));
		sList.add(new Statement(7000L,1,"</el-option>"));
		sList.add(new Statement(8000L,0,"</el-select>"));
		sList.add(new Statement(9000L,0,""));
		sList.add(new Statement(10000L,0,"<el-select v-model=\"dataType\" placeholder=\"请选择\"  @change=\"setup\">"));
		sList.add(new Statement(11000L,1,"<el-option"));
		sList.add(new Statement(12000L,1,"v-for=\"item in dataTypes\""));
		sList.add(new Statement(13000L,1,":key=\"item.value\""));
		sList.add(new Statement(14000L,1,":label=\"item.label\""));
		sList.add(new Statement(15000L,1,":value=\"item.value\">"));
		sList.add(new Statement(16000L,1,"</el-option>"));
		sList.add(new Statement(17000L,0,"</el-select>"));
		sList.add(new Statement(18000L,0,""));
		sList.add(new Statement(19000L,0,"<div id=\"main\" ref=\"chart\" :style=\"{width: '1000px', height: '600px'}\"></div>"));

		StatementList sl = WriteableUtil.merge(sList);
		sl.setSerial(this.serial);
		return sl;
	}

	@Override
	public StatementList generateWidgetScriptStatements() {
		try {
			List<Writeable> sList = new ArrayList<>();
			long serial = 0L;

			StatementList sl = WriteableUtil.merge(sList);
			sl.setSerial(this.serial);
			return sl;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public boolean parse() {
		return true;
	}

	public FrontDomain getDomain() {
		return domain;
	}

	public void setDomain(FrontDomain domain) {
		this.domain = domain;
	}

}
